/**
 * Copyright 2010 Per-Erik Bergman (per-erik.bergman@jayway.com)
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package com.opengltest;

/**
 * SimplePlane is a setup class for Mesh that creates a plane mesh.
 * 
 * @author Per-Erik Bergman (per-erik.bergman@jayway.com)
 * 
 */
public class SimpleCube extends Mesh {
	
	float width;
	float height;
	float depth;
	/**
	 * Create a plane with a default with and height of 1 unit.
	 */
	public SimpleCube() {
		this(1, 1,1);
	}

	/**
	 * Create a plane.
	 * 
	 * @param width
	 *            the width of the plane.
	 * @param height
	 *            the height of the plane.
	 */
	public SimpleCube(float width, float height,float depth) {
		
		this.width  = width;
		this.height = height;
		this.depth  = depth;
		
		width  /= 2;
		height /= 2;
		depth  /= 2;
		// Mapping coordinates for the vertices
		//纹理坐标
		float textureCoordinates[] = {
				0.0f, 2.0f, //
				2.0f, 2.0f, //
				0.0f, 0.0f, //
				2.0f, 0.0f, //
		};

		//顶点顺序
		short indices[] = { 
				 0, 4, 5,
				 0, 5, 1,
				 1, 5, 6,
				 1, 6, 2,
				 2, 6, 7,
				 2, 7, 3,
				 3, 7, 4,
				 3, 4, 0,
				 4, 7, 6,
				 4, 6, 5,
				 3, 0, 1,
				 3, 1, 2, };

		//顶点
		float vertices[] = { 
				-width, -height, -depth, // 0
				 width, -height, -depth, // 1
				 width,  height, -depth, // 2
				-width,  height, -depth, // 3
				-width, -height,  depth, // 4
				 width, -height,  depth, // 5
				 width,  height,  depth, // 6
				-width,  height,  depth, // 7
				 };

		setIndices(indices);
		setVertices(vertices);
//		setTextureCoordinates(textureCoordinates);
	}
}
